package com.yc.cloud.common.websocket.controller;

import com.yc.cloud.common.basic.api.ResponseResult;
import com.yc.cloud.common.websocket.dto.request.PlayerListParam;
import com.yc.cloud.common.websocket.service.SocketService;
import com.yc.cloud.common.websocket.vo.PlayerVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.val;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/player")
@RestController
@Api(tags = "玩家接口")
public class PlayerController {

    private final SocketService socketService;

    public PlayerController(SocketService socketService) {
        this.socketService = socketService;
    }

    @RequestMapping("/list")
    @ApiOperation(value = "在线玩家列表", notes = "在线玩家列表")
    public ResponseResult<List<PlayerVo>> list(PlayerListParam param) {
        val onLineUsers = socketService.getOnLineUsers();
        return ResponseResult.success(onLineUsers);
    }

}
